package eerbaar.v2.app.java2d;

import java.awt.Graphics2D;
import java.awt.Image;

import eerbaar.v2.app.core.ISprite;

public class Java2DSprite implements ISprite {

    private final Image image;

    public Java2DSprite(Image image) {
        this.image = image;
    }

    @Override
    public void draw(Graphics2D g, int x, int y) {
        g.drawImage(this.image, x, y, null);
    }

    @Override
    public void drawSquare(Graphics2D g, int x, int y) {
        int height = this.getHeight();
        int width = this.getWidth();
        int q = Math.min(height, width);

        g.drawImage(this.image, x, y, x + q, y + q, 0, 0, q, q, null);
    }

    @Override
    public int getHeight() {
        return this.image.getHeight(null);
    }

    @Override
    public Image getImage() {
        return this.image;
    }

    @Override
    public int getWidth() {
        return this.image.getWidth(null);
    }

}